package zj.com.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

import zj.com.model.Dic;
import zj.com.zj.R;

/**
 * Created by xi on 16/6/3.
 */
public class SelectJcdAdapter extends BaseAdapter{

    public List<Dic> list;
    public Context context;
    public LayoutInflater inflater;

    public boolean isEdit = false;

    public SelectJcdAdapter(List<Dic> list, Context context){

        this.list = list;
        this.context = context;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = new ViewHolder();
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.adapter_select_item, null);
            viewHolder.name_tv = (TextView) convertView.findViewById(R.id.name_tv);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }


        Dic dic = list.get(position);
        viewHolder.name_tv.setText(dic.getName());

        return convertView;
    }
    private static class ViewHolder {
        TextView name_tv;

    }

    public void setDataChange(List<Dic> list){


        this.list = list;
        notifyDataSetChanged();
    }

}
